<?php
//=========
$bduss=array ("");//请填写bduss值,并按array ("bduss值1","bduss值2","bduss值3");规则填写
$kw="chrome";//请填写吧名
$sleep=2;//由于快速点赞只能连续成功4或5，就必须设置间隔了。。。
$sp=1;//暂停间隔
//=========
$zan_num=-1;
function curl_client($pda,$url="http://c.tieba.baidu.com/c/f/frs/page"){
	global $bduss;
	$header = array ("Content-Type: application/x-www-form-urlencoded");
	$pda=array_merge(array("BDUSS=".$bduss[0],
		"_client_id=wappc_1396611108603_817",
		"_client_type=2",
		"_client_version=5.7.0",
		"_phone_imei=642b43b58d21b7a5814e1fd41b08e2a6",
		"from=tieba"),$pda);
	$data=implode("&", $pda)."&sign=".md5(implode("", $pda)."tiebaclient!!!");
	//echo $data.'<br>';
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	$re = json_decode(curl_exec($ch)); 
	curl_close($ch);
	return $re;
}
function curl_client2($pda,$url="http://c.tieba.baidu.com/c/f/frs/page",$b){
	$header = array ("Content-Type: application/x-www-form-urlencoded");
	$pda=array_merge(array("BDUSS=".$b,
		"_client_id=wappc_1396611108603_817",
		"_client_type=2",
		"_client_version=5.7.0",
		"_phone_imei=642b43b58d21b7a5814e1fd41b08e2a6",
		"action=like",
		"from=tieba"),$pda);
	$data=implode("&", $pda)."&sign=".md5(implode("", $pda)."tiebaclient!!!");
	//echo $data.'<br>';
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	$re = json_decode(curl_exec($ch)); 
	curl_close($ch);
	return $re;
}
function get_list(){
	global $kw,$bduss,$sleep,$zan_num,$sp;
	$data=array("kw=".$kw,
            "pn=1",
            "q_type=2",
            "rn=50",
            "with_group=1");
	$re=curl_client($data,"http://c.tieba.baidu.com/c/f/frs/page");
	//print_r($re);
	//return;
	$re=$re->thread_list;
	echo "已找到未点赞的贴子:<br>";
	foreach ($re as $key => $value) {
		if($value->zan->is_liked==0){
			$zan_num++;
			if($zan_num>0&&$zan_num%$sp==0){
				sleep($sleep);
				echo "暂停".$sleep."秒<br>";
			}
			echo $value->title.":";
			$pid=$value->first_post_id;
			$tid=$value->id;
			for($i=0;$i<count($bduss);$i++){
				$data=array("kw=".$kw,
					"post_id=".$pid,
					"thread_id=".$tid);
				$re=curl_client2($data,"http://c.tieba.baidu.com/c/c/zan/like",$bduss[$i]);
				if($re->error_code==0)echo "√";
				else echo "×";
			}
			echo "<br>";
		}
	}
}
get_list();
?>